export const homepopList = {
  created(){
    
  },
  methods: {
    handleRemovePoster() {
      this.form.smartPopupPicture = "";
      this.form.smartPopupPictureId = "";
    },
    uploadSuccessCallback(res) {
      this.form.smartPopupPictureId = res;
      this.$message.success(this.$t('table_data.operasucc'))
    },
    getPosterFile(file){
      if(file.status === 'success') {
        this.form.smartPopupPicture = file.tempFile;
      }
    },
  },
  data() {
    var checkFileId = (rule, value, callback) => {
      if (!this.form.smartPopupPictureId) {
        return callback(new Error(this.$t('formRule.file_rule')));
      } else {
        callback()
      }
    };
    var checkShortId = (rule, value, callback) => {
      if (!this.form.typeId) {
        return callback(new Error(this.$t('formRule.selectPlaceholder')));
      } else {
        callback()
      }
    };
    var checkedUsers = (rule, value, callback) => {
      if (!this.form.checkedUser || this.form.checkedUser.length == 0) {
        return callback(new Error(this.$t('formRule.selectPlaceholder')));
      } else {
        callback()
      }
    };
    
    return {
      defaultTime: [new Date(2000,1,1,0,0,0), new Date(2000,1,1,23,59,59)],
      showUpload: false,
      action: '#',
      form: {
        id: "",
        buttonStatus: 0,
        closeTime: 1,
        theme: {en_US: '',ja_JP: '',zh_CN: '',zh_TW: ''},
        title: {en_US: '',ja_JP: '',zh_CN: '',zh_TW: ''},
        content: {en_US: '',ja_JP: '',zh_CN: '',zh_TW: ''},
        buttonName: {en_US: '',ja_JP: '',zh_CN: '',zh_TW: ''},
        smartPopupPicture: "",
        smartPopupPictureId: "",
        type: 1,
        typeId: "",
        showType: 3,
        userType: 1,
        startTime: "",
        endTime: "",
        closeType: 1,
        clickCount: 1,
        targetType: 1,
        estimatedDeviceCount: 0,
        sort: 0,
        userTest: []
        // checkedCities: [],
        // checkedUser: [],
        // model: "",
        // signUpTimeType: "1",
        // signUpTime: [new Date().getTime()-3600*1000*24*30, new Date().getTime()],
        // radio1: 1,

      },
      showTime: [],
      isIndeterminate: false,
      isIndeterminateUser: false,
      checkAll: false,
      checkAllUser: false,
      cities: [],
      users: [],
      userStatus: [
        {
          name: this.$t('homepopListFormLabel.userStatusAll'),
          value: 1
        },
        {
          name: this.$t('homepopListFormLabel.userStatusLogged'),
          value: 2
        },
        {
          name: this.$t('homepopListFormLabel.userStatusUnLogin'),
          value: 3
        }
      ],
      dialogInfo: {
        langurage: "ja_JP",
        langList: [
          {
            name: '简体中文',
            value: 'zh_CN',
          },
          {
            name: '繁體中文',
            value: 'zh_TW',
          },
          {
            name: 'English',
            value: 'en_US',
          },
          {
            name: '日本語',
            value: 'ja_JP',
          }
        ]
      },
      timeZoneType: [
        {
          name: 'Asia/Beijing',
          value: 'Asia/Shanghai',
          utc: 8
        },
        {
          name: 'Asia/Tokyo',
          value: 'Asia/Tokyo',
          utc: 9
        },
        {
          name: 'America/New_York',
          value: 'America/New_York',
          utc: -4
        }
      ],
      targetType: [
        // {
        //   name: this.$t('subscript_list.formLabel.Customize'),
        //   value: 3
        // },
        {
          name: this.$t('subscript_list.formLabel.allUser'),
          value: 1
        },
        {
          name: this.$t('subscript_list.formLabel.testUser'),
          value: 2
        }
      ],
      appLinkList: [
        {
          name: '短剧',
          type: 1
        }
      ],
      shortList: [],
      modelList: [
        {
          label: this.$t('subscript_list.formLabel.phoneAll'),
          value: 0,
        },
        {
          label: this.$t('subscript_list.formLabel.ios'),
          value: 1,
          children: [
            {
              label: this.$t('subscript_list.formLabel.phoneAll'),
              value: 1,
            }
          ]
        },
        {
          label: this.$t('subscript_list.formLabel.android'),
          value: 2,
          children: [
            {
              label: this.$t('subscript_list.formLabel.phoneAll'),
              value: 1,
            }
          ]
        }
      ],
      userUseTimeList: [
        {
          name: this.$t('subscript_list.formLabel.specifyTime'),
          value: "1"
        },
        {
          name: this.$t('subscript_list.formLabel.allTime'),
          value: "2"
        },
      ],
      payTypeList: [
        {
          name: this.$t('subscript_list.formLabel.selectAll'),
          value: "1"
        },
      ],
      props: {
        expandTrigger: "hover",
      },
      rules: {
        // targetType: 1,
        // estimatedDeviceCount: 0,
        "theme.en_US": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "theme.ja_JP": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "theme.zh_CN": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "theme.zh_TW": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "buttonName.en_US": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "buttonName.ja_JP": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "buttonName.zh_CN": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "buttonName.zh_TW": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "title.en_US": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "title.ja_JP": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "title.zh_CN": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "title.zh_TW": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "content.en_US": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "content.ja_JP": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "content.zh_CN": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "content.zh_TW": [
          {required: true, message: this.$t('formRule.inputPlaceholder'), trigger:'blur'}
        ],
        "buttonStatus": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "type": [
          {required: true, validator: checkShortId, trigger:'change'}
        ],
        "smartPopupPictureId": [
          {required: true, validator: checkFileId, trigger:'change'}
        ],
        "closeType": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],

        "sendTime": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "timezone": [
          {required: true, message: this.$t('formRule.selectPlaceholder'), trigger:'change'}
        ],
        "checkedUser": [
          {required: true, validator: checkedUsers, trigger:'change'}
        ],
        
      },

    }
  },
}
